<?php

use console\db\Migration;

/**
 * 更新用户注册时间
 * 
 * @author emhome <emhome@163.com>
 * @since 1.0
 */
class m300000_000009_t_user_meta_created_at extends Migration {

    /**
     * @inheritdoc
     */
    public function safeUp() {
        $tableName = '{{%user_meta}}';
        $user = '{{%user}}';
        $condition = 'a.id=b.id';
        $set = [
            'a.created_at=b.created_at'
        ];
        $sql = "update {$tableName} a inner join {$user} b on {$condition} set " . implode(',', $set);
        $this->db->createCommand($sql)->execute();
    }

}
